from django.db import models
from user.models import SysUser   # 指向 user 应用的 SysUser


class Conversation(models.Model):
    """
    一个完整的会话，对应 Coze 的 conversation_id
    """
    conversation_id = models.CharField(
        max_length=64,
        unique=True,
        db_index=True,
        help_text="Coze 返回的会话标识"
    )
    user = models.ForeignKey(
        SysUser,
        on_delete=models.CASCADE,
        db_column="user_id",
        related_name="conversations"
    )
    status = models.CharField(
        max_length=20,
        choices=[("active", "活跃"), ("closed", "已关闭")],
        default="active"
    )
    name = models.CharField(max_length=100, null=True, blank=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        db_table = "conversation"
        ordering = ["-created_at"]


# class Product(models.Model):
